import { getInsuranceStaffRecordList } from '@/api/insurance/staff'
import type { InsuranceStaffRecordDto } from '@/api/insurance/staff/types'
import { getKeyToEnum, InsuranceOrderStatusCnEnum, PolicyStatusCnEnum } from '@/const/enum'
import type { FilterDto } from '@/render/FilterRender'
import TableRender, { type TableRenderColumnTypes } from '@/render/TableRender'
import toNative from '@/utils/toNative'
import { Component } from 'vue-facing-decorator'

@Component
export class CompanyBlack extends TableRender {
    filterConfig() {
        return {
            name: {
                name: '员工姓名',
                element: 'input'
            },
            product: {
                name: '身份证号',
                element: 'input'
            },
            operate: {
                name: '状态',
                element: 'select',
                options: getKeyToEnum(InsuranceOrderStatusCnEnum)
            }
        } as FilterDto
    }
    tableColumnConfig() {
        return [
            {
                field: 'userName',
                title: '员工姓名',
            },
            {
                field: 'idCardNo',
                title: '身份证号',
                slots: {
                    default: 'idcard'
                },
                width: 160,
            },
            {
                field: 'sourceName',
                title: '数据来源',
            },
            {
                field: 'insureStartTime',
                title: '在保时间',
            },
            {
                field: 'policyStatus',
                title: '状态',
                params: {
                    enum: PolicyStatusCnEnum
                },
                slots: {
                    default: 'enum',
                }
            },
            {
                field: 'companyPlanName',
                title: '方案简称'
            },
            {
                field: 'companyName',
                title: '客户名称',
            },
            {
                field: 'serveCompanyName',
                title: '派遣单位',
            },
            {
                field: 'occupationName',
                title: '工种',
            },
            {
                field: 'occupationLevel',
                title: '风险等级',
            },
            {
                field: 'updateUserName',
                title: '操作人',
            },
            {
                field: 'updateTime',
                title: '最近更新时间',
            },
            {
                field: 'createTime',
                title: '操作',
            },
        ] as TableRenderColumnTypes<InsuranceStaffRecordDto>
    }
    
    onLoadData(page: number, size: number, filters: any) {
        return getInsuranceStaffRecordList({
            pageNum: page,
            pageSize: size,
            ...filters
        })
    }
}

export default toNative(CompanyBlack)